<?php

namespace app\common\library;

/**
 * create by PhpStorm 2025/9/23 10:59
 * bus.com app\common\library@Gps
 * 行止之行 <xingzhi8711@gmail.com>
 * GPS定位接口对接
 */
class Gps
{
    private $account="hygd250918";
    private $password="Bb,7Y2J*v19^";
    private $header;
    private $baseUrl="http://112.91.140.161:14003/api/";

    public function __construct()
    {
        $requireTime=date("YmdHisv");
        $auth=md5(md5($this->account.$requireTime.$this->password));
        $this->header=[
            'auth:'. $auth,
            'reqtime:'. $requireTime
        ];
    }
    /*单个定位*/
    public function getVeh($cardid)
    {
        $url=$this->baseUrl."getVehNewestGps";
        setLog(__METHOD__,$url);
        setLog(__METHOD__,$this->header);
        setLog(__METHOD__,json_encode($cardid,JSON_UNESCAPED_UNICODE));
        $result=httpCurl::postData(json_encode(['cardid'=>$cardid],256), $this->header,$url);
        return $result;
    }
    /*批量定位*/
    public function getVehBatch($cardid)
    {
        $url=$this->baseUrl."getVehNewestGpsBatch";
        $result=httpCurl::postData(json_encode(['cardid'=>$cardid]), $this->header,$url);
        return $result;
    }
    /*获取轨迹*/
    public function getSeltrack($option)
    {
        $url=$this->baseUrl."seltrackapi";
        setLog(__METHOD__,$url);
        setLog(__METHOD__,$this->header);
        setLog(__METHOD__,json_encode($option,JSON_UNESCAPED_UNICODE));
        return httpCurl::postData(json_encode($option,256), $this->header,$url);
    }

}